package com.strange.mdl.module.mdl.dal.mysql.sutras;

import com.strange.mdl.framework.common.pojo.PageResult;
import com.strange.mdl.framework.mybatis.core.query.LambdaQueryWrapperX;
import com.strange.mdl.framework.mybatis.core.mapper.BaseMapperX;
import com.strange.mdl.module.mdl.controller.admin.sutras.vo.sutras.MdlSutrasPageReqVO;
import com.strange.mdl.module.mdl.controller.app.sutras.vo.AppMdlSutrasPageReqVO;
import com.strange.mdl.module.mdl.dal.dataobject.sutras.MdlSutrasDO;
import org.apache.ibatis.annotations.Mapper;

/**
 * 经书 Mapper
 *
 * @author 密谛灵总控
 */
@Mapper
public interface MdlSutrasMapper extends BaseMapperX<MdlSutrasDO> {

    default PageResult<MdlSutrasDO> selectPage(MdlSutrasPageReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperX<MdlSutrasDO>()
                .likeIfPresent(MdlSutrasDO::getSutraName, reqVO.getSutraName())
                .orderByDesc(MdlSutrasDO::getId));
    }

    default PageResult<MdlSutrasDO> selectPage(AppMdlSutrasPageReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperX<MdlSutrasDO>()
                .likeIfPresent(MdlSutrasDO::getSutraName, reqVO.getSutraName())
                .eqIfPresent(MdlSutrasDO::getCoverUrl, reqVO.getCoverUrl())
                .eqIfPresent(MdlSutrasDO::getCategoryId, reqVO.getCategoryId())
                .eqIfPresent(MdlSutrasDO::getStatus, reqVO.getStatus())
                .orderByDesc(MdlSutrasDO::getId));
    }
}